package com.eastfair.venuebooking.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.eastfair.boot.request.PageParams;
import com.eastfair.boot.service.SuperService;
import com.eastfair.pay.dto.InvoiceCallbackDTO;
import com.eastfair.venuebooking.dto.ContractManageAssignDTO;
import com.eastfair.venuebooking.dto.ContractManageDTO;
import com.eastfair.venuebooking.dto.ContractManageQuery;
import com.eastfair.venuebooking.dto.FollowRecordPlanSaveDTO;
import com.eastfair.venuebooking.entity.ContractManage;
import com.eastfair.venuebooking.vo.ContractHistogramVO;
import com.eastfair.venuebooking.vo.ContractManageVO;

import java.util.List;

/**
 * <p>
 * 业务接口
 * 合同
 * </p>
 *
 * @author lyw
 * @date 2022 -06-20
 */
public interface ContractManageService extends SuperService<ContractManage> {

    /**
     * 查询合同列表.
     *
     * @param pageParams the page params
     * @return the page
     */
    IPage<ContractManageVO> listContractManageVOs(PageParams<ContractManageQuery> pageParams);

    /**
     * id查询详情.
     *
     * @param id the id
     * @return the contract manage vo
     */
    ContractManageVO getContractManageVOById(Long id);

    /**
     * 合同编号获取合同VO.
     *
     * @param contractNumber the contract number
     * @return the vo by contract number
     */
    ContractManageVO getVOByContractNumber(String contractNumber);

    /**
     * 合同编号获取合同.
     *
     * @param contractNumber the contract number
     * @return the by contract number
     */
    ContractManage getByContractNumber(String contractNumber);

    /**
     * 查询合同列表.
     *
     * @param contractManageQuery the contract manage query
     * @return the list
     */
    List<ContractManage> listContractManage(ContractManageQuery contractManageQuery);

    /**
     * 客户ID查询合同列表.
     *
     * @param customerId the customer id
     * @return the list
     */
    List<ContractManage> listContractManageByCustomerId(Long customerId);

    /**
     * 展会ID查询合同列表.
     *
     * @param exhibitionId the exhibition id
     * @return the list
     */
    List<ContractManage> listContractManageByExhibitionId(Long exhibitionId);

    /**
     * 合同ID列表查询合同列表.
     *
     * @param ids the ids
     * @return the list
     */
    List<ContractManageVO> listVOByIds(List<Long> ids);

    /**
     * 计划付款时间范围查询未付款的合同.
     *
     * @param startPlanPayTime the start plan pay time
     * @param endPlanPayTime   the end plan pay time
     * @return the list
     */
    List<ContractManageVO> listByPlanPayTime(String startPlanPayTime, String endPlanPayTime);

    /**
     * 客户ID统计合同金额.
     *
     * @param customerId the customer id
     * @return the contract manage vo
     */
    ContractManageVO countContractManageByCustomerId(Long customerId);

    /**
     * 客户ID查询每年的成交量.
     *
     * @param id the id
     * @return the map
     */
    List<ContractHistogramVO> countEveryYearContractAmountByCustomerId(Long id);

    /**
     * 合同是否存在.
     *
     * @param query the customer ids
     * @return the list
     */
    boolean existContractManage(ContractManageQuery query);

    /**
     * 通过客户ID查询合同是否存在.
     *
     * @param customerId the customer id
     * @return the boolean true：存在/false：不存在
     */
    boolean existContractManageByCustomerIds(List<Long> customerId);

    /**
     * 通过报价书ID查询合同是否存在.
     *
     * @param quotationIds the quotation ids
     * @return the boolean
     */
    boolean existContractManageByQuotationIds(List<Long> quotationIds);

    /**
     * 保存合同.
     *
     * @param saveDTO the save dto
     * @return the boolean
     */
    boolean saveContract(ContractManageDTO saveDTO);

    /**
     * 修改合同.
     *
     * @param saveDTO the save dto
     * @return the boolean
     */
    boolean updateContract(ContractManageDTO saveDTO);

    /**
     * 批量ID更新合同为失效.
     *
     * @param ids the ids
     * @return the boolean
     */
    boolean updateContractDisableByIds(List<Long> ids);

    /**
     * 展会ID更新合同为失效.
     *
     * @param exhibitionId the exhibition id
     * @return the boolean
     */
    boolean updateContractDisableByExhibitionId(Long exhibitionId);

    /**
     * 更新合同和报价书为失效.
     *
     * @param exhibitionId the exhibition id
     * @return the boolean
     */
    boolean updateContractAndQuotationDisableByExhibitionId(Long exhibitionId);

    /**
     * 支付之后更新合同，更新回款金额和付款状态.
     *
     * @param contractManageDTO the contract manage dto
     * @return the boolean
     */
    boolean updateContractForCollect(ContractManageDTO contractManageDTO);

    /**
     * 确认合同.
     *
     * @param id the id
     * @return the boolean
     */
    boolean updateContractStatusApproved(Long id);

    /**
     * 更新归属人.
     *
     * @param assignDTO the assign dto
     * @return the boolean
     */
    boolean updateBelongTo(ContractManageAssignDTO assignDTO);

    /**
     * 更新归属.
     *
     * @param updateDTO the update dto
     * @return the boolean
     */
    boolean updateBelongTo(ContractManageDTO updateDTO);

    /**
     * 更新跟进信息.
     *
     * @param updateDTO the update dto
     * @return the boolean
     */
    boolean updateFollow(ContractManageDTO updateDTO);

    /**
     * 更新跟进信息.
     *
     * @param followRecordPlanSaveDTO the follow record plan save dto
     * @return the boolean
     */
    boolean updateFollow(FollowRecordPlanSaveDTO followRecordPlanSaveDTO);

    /**
     * @return void
     * @Author clm
     * @Description 开票回填
     * @Date 14:42 2022/7/14
     * @Param [invoiceCallbackDTO]
     **/
    void updateForInvoice(InvoiceCallbackDTO invoiceCallbackDTO);

    /**
     * 删除合同.
     *
     * @param ids the ids
     * @return the boolean
     */
    boolean removeContractByIds(List<Long> ids);

    /**
     * 展会ID删除合同.
     *
     * @param exhibitionId the exhibition id
     * @return the boolean
     */
    boolean removeContractByExhibitionId(Long exhibitionId);

    /**
     * 保存支付系统交易订单.
     *
     * @param contractManageDTO the contract manage dto
     * @return the boolean
     */
    boolean saveTransactionOrder(ContractManageDTO contractManageDTO);

    /**
     * 保存支付系统交易订单.
     *
     * @param contractNumber the contract number
     * @return the boolean
     */
    boolean saveTransactionOrder(String contractNumber);

    /**
     * 更新支付系统交易订单.
     *
     * @param contractManageDTO the contract manage dto
     * @return the boolean
     */
    boolean updateTransactionOrder(ContractManageDTO contractManageDTO);

    /**
     * 合同付款计划到期支付站内信提醒.
     *
     * @param contractManageVO the contract manage vo
     * @return the boolean
     */
    boolean sendInnerMsgWhenPayPlanDeadLine(ContractManageVO contractManageVO);

    /**
     * 异步合同付款计划到期支付站内信提醒.
     *
     * @param contractManageVO the contract manage vo
     */
    void asyncSendInnerMsgWhenPayPlanDeadLine(ContractManageVO contractManageVO);
}
